﻿<style>
    .control-label i {
        color: red;
    }
</style>
<script>


    var tempmodel = avalon.define({
        $id: "XXFB",
        name: "企业信息",
        ColumnData: [],
        modelData: { "isPL": true, "XXFBType": "", "FBTime": "", "JSUser": "", "IsSecret": true, "Files": "", "JSUser": "", "MsgType": 1, "IsSend": "0", "SHUser": "", "IsSH": false },
        XXFBDataList: [{ "index": 0, "ID": 0, "XXTitle": "", "XXContent": "", "Files": "", "Author": "", "ImageIds": "", isselect: true, isshow: true, "filehtml": "", "fmtphtml": "" }, { "index": 1, "ID": 0, "XXTitle": "", "XXContent": "", "Files": "", "Author": "", "ImageIds": "", isselect: false, isshow: false, "filehtml": "", "fmtphtml": "" }, { "index": 2, "ID": 0, "XXTitle": "", "XXContent": "", "Files": "", "Author": "", "ImageIds": "", isselect: false, isshow: false, "filehtml": "", "fmtphtml": "" }, { "index": 3, "ID": 0, "XXTitle": "", "XXContent": "", "Files": "", "Author": "", "ImageIds": "", isselect: false, isshow: false, "filehtml": "", "fmtphtml": "" }, { "index": 4, "ID": 0, "XXTitle": "", "XXContent": "", "Files": "", "Author": "", "ImageIds": "", isselect: false, isshow: false, "filehtml": "", "fmtphtml": "" }],
        showindex: 0,
        iswf: false,//是否属于流程表单
        strModelId: 0,
        inittemp: function (strId) {
            $.getJSON('/API/VIEWAPI.ashx?Action=XXFB_GETXXFBCHILDRENMANAGE',{}, function (resultData) {
                if (resultData.ErrorMsg == "") {
                    tempmodel.ColumnData = resultData.Result;
                }
            })

            if (strId) {
                tempmodel.strModelId = strId;
                //编辑加载数据
                $.getJSON('/API/VIEWAPI.ashx?Action=XXFB_GETXXFBMODEL', { P1: strId }, function (resultData) {
                    if (resultData.ErrorMsg == "") {
                        resultData.Result.isPL = resultData.Result.isPL == 0 ? false : true;
                        resultData.Result.IsSecret = resultData.Result.IsSecret.toLowerCase() == "true" ? true : false;
                        tempmodel.modelData = resultData.Result;
                        if (tempmodel.modelData.FBTime)
                        {
                            tempmodel.modelData.FBTime = tempmodel.modelData.FBTime.substring(0, 16);
                        }
                        $(resultData.Result4).each(function (i, item) {
                            tempmodel.XXFBDataList[i].ID = item.ID;
                            tempmodel.XXFBDataList[i].XXTitle = item.XXTitle;
                            tempmodel.XXFBDataList[i].XXContent = item.XXContent;
                            tempmodel.XXFBDataList[i].Files = item.Files;
                            tempmodel.XXFBDataList[i].Author = item.Author;
                            tempmodel.XXFBDataList[i].isshow = true;
                            tempmodel.XXFBDataList[i].ImageIds = item.ImageIds;
                        })
                        setTimeout("ComFunJS.initForm()", 500)
                    }
                })
            } else {
                ComFunJS.initForm();
                tempmodel.InitBtn();
            }
        }, InitBtn: function () {
            var $footbar
            $footbar = $("<tr><td class='text-center' style='border-top:0'><span class='input-group-btn'><button class='btn btn-info btncg' style='width:120px;height:40px;'>存为草稿</button><button class='btn btn-warning btnyl' style='width:120px;height:40px;'>预览</button><button class='btn btn-success btnfb' style='width:120px;height:40px;'>发布</button></span><td></tr>");
            $footbar.find(".btncg").click(function () {
                if (tempmodel.modelData.FBTime == "" && tempmodel.timeShow) {
                    top.ComFunJS.winwarning("请选择定时时间");
                    return false;
                }
                if (!tempmodel.modelData.JSUser) {
                    top.ComFunJS.winwarning("请选择接收人");
                    return;
                }
                pmodel.SaveData(this, false);
            })
            $footbar.find(".btnfb").click(function () {
                if (tempmodel.modelData.FBTime == "" && tempmodel.timeShow) {
                    top.ComFunJS.winwarning("请选择定时时间");
                    return false;
                }
                if (!tempmodel.modelData.JSUser) {
                    top.ComFunJS.winwarning("请选择接收人");
                    return;
                }
                pmodel.SaveData(this, false);
            })
            $footbar.find(".btnyl").click(function () {
                if (tempmodel.XXFBDataList[0].XXTitle) {
                    top.$("body").data("XXFBDataList", JSON.stringify(tempmodel.XXFBDataList.$model));
                    top.ComFunJS.winviewform("/ViewV5/AppPage/XXFB/XXFBChildrenVIEW.html?isYL=Y&&index=" + tempmodel.showindex, "企业发布预览", "1000", "");
                } else {
                    top.ComFunJS.winwarning("请添加图文信息");
                }
            })

            $(".toolfootbar tbody").empty().append($footbar);
        },//初始化
        ShowTab: function (item) {
            //切换tab
            tempmodel.XXFBDataList[tempmodel.showindex + 1 * 1].isshow = true;
            tempmodel.XXFBDataList.forEach(function (el) {
                el.isselect = false
            })
            tempmodel.XXFBDataList[tempmodel.showindex + 1 * 1].isselect = true;
            tempmodel.showindex++;
        },
        SelTab: function (item) {
            tempmodel.XXFBDataList.forEach(function (el) {
                el.isselect = false
            })
            tempmodel.showindex = item.index;
            item.isselect = true;
        },
        hidTab: function (item, event) {
            event.stopPropagation();
            if (tempmodel.showindex == item.index) {
                tempmodel.showindex = item.index - 1;
                tempmodel.XXFBDataList[tempmodel.showindex].isselect = true;

            }
            item.isshow = false;
            item.isselect = false;
            item.XXTitle = "";
            item.XXContent = "";
            item.Author = "";
            item.ImageIds = "";
            item.filehtml = "";
            item.fmtphtml = "";


        },
        SaveData: function (callback, btdom) {

            tempmodel.modelData.isPL = tempmodel.modelData.isPL ? 1 : 0;
            if ($(btdom).hasClass("btncg")) {
                tempmodel.modelData.IsSend = "0";
                $.post("/API/VIEWAPI.ashx?ACTION=XXFB_ADDXXFB", { P1: JSON.stringify(tempmodel.modelData.$model), P2: JSON.stringify(tempmodel.XXFBDataList.$model) }, function (result) {
                    tempmodel.ReSetInit();
                    return callback.call(this, result);
                });
            } else if ($(btdom).hasClass("btnfb")) {
                tempmodel.modelData.IsSend = "1";
                top.ComFunJS.winconfirm("确认要发布新闻公告吗？", function () {

                    $.post("/API/VIEWAPI.ashx?ACTION=XXFB_ADDXXFB", { P1: JSON.stringify(tempmodel.modelData.$model), P2: JSON.stringify(tempmodel.XXFBDataList.$model) }, function (result) {
                        tempmodel.ReSetInit();
                        return callback.call(this, result);
                    });
                }, function () {
                    $(btdom).attr("disabled", false).find(".fa").hide();//加上转圈样式
                })
            } else {//信息发布修改
                top.ComFunJS.winconfirm("确认要修改新闻公告吗？", function () {

                    $.post("/API/VIEWAPI.ashx?ACTION=XXFB_XXFBMODIFY", { P1: JSON.stringify(tempmodel.modelData.$model), P2: JSON.stringify(tempmodel.XXFBDataList.$model) }, function (result) {
                        return callback.call(this, result);
                    });
                }, function () {
                    $(btdom).attr("disabled", false).find(".fa").hide();//加上转圈样式
                })
            }

        }, isAnyUser: 0, TypeIsCheck: function () {
            var Id = $("#conXXType").val();
            tempmodel.modelData.XXFBType = Id;
            if (Id) {
                tempmodel.modelData.SHUser = "";
                var CheckUserItem;
                tempmodel.ColumnData.forEach(function (val) {
                    $(".toolfootbar tbody tr td span").find("select").remove();
                    if (val.ID == Id) {
                        CheckUserItem = val;
                        tempmodel.modelData.IsSH = (val.IsCheck.toLowerCase() == 'true');
                        if (val.IsSee && val.IsSee == "True") {
                            if (val.SeeUser) {
                                tempmodel.modelData.JSUser = val.SeeUser;
                                tempmodel.isAnyUser = 1;
                            } else {
                                tempmodel.isAnyUser = 0;
                                tempmodel.modelData.JSUser = "";
                            }
                            ComFunJS.initForm();
                        } else {
                            tempmodel.isAnyUser = 0;
                            tempmodel.modelData.JSUser = "";
                            ComFunJS.initForm();
                        }

                    }
                })

                if (CheckUserItem && CheckUserItem.IsCheck.toLowerCase() == "true" && tempmodel.modelData.IsSend == 0 && CheckUserItem.CheckUser) {
                    tempmodel.modelData.SHUser = CheckUserItem.CheckUser;
                }
            }
        }, GetDraftInfo: function (fun, dec) {

            top.ComFunJS.winbtnwin("/ViewV5/AppPage/XXFB/" + fun + ".html", dec, 800, 540, {}, function (layero, index) {
                var frameid = $("iframe", $(layero)).attr('id');
                var xxfbData = ComFunJS.isIE() ? top.window.frames[frameid].selmodel.GetSelModel() : top.window.frames[frameid].contentWindow.selmodel.GetSelModel();

                if (xxfbData.ComId) {
                    if (fun == "SelDraft") {
                        tempmodel.modelData = xxfbData;
                        tempmodel.TypeIsCheck(xxfbData.XXFBType);
                        tempmodel.XXFBDataList = JSON.parse(xxfbData.Remark);
                    } else {
                        tempmodel.XXFBDataList = xxfbData.Content;
                    }

                    $(tempmodel.XXFBDataList.$model).each(function (i, val) {
                        tempmodel.XXFBDataList[i].isselect = i == 0 ? true : false;
                        tempmodel.XXFBDataList[i].isshow = val.XXTitle != "" ? true : false;
                    })
                    setTimeout(" ComFunJS.initForm()", 500)
                    top.layer.close(index)
                } else {
                    ComFunJS.winwarning("请选择" + (fun == "SelDraft" ? "草稿" : "素材"));
                }
            })
        }, timeShow: false
        , IsShowTime: function (dom) {
            tempmodel.timeShow = $(dom).attr("checked");
        }, ReSetInit: function () {
            tempmodel.XXFBDataList.clear();
            tempmodel.modelData = { "isPL": true, "XXFBType": "", "FBTime": "", "JSUser": "", "IsSecret": true, "Files": "", "JSUser": "", "MsgType": 1, "IsSend": "0", "SHUser": "", "IsSH": false };
            tempmodel.XXFBData = { "index": 0, "XXTitle": "", "XXContent": "", "Files": "", "Author": "", "ImageIds": "", isselect: true, isshow: true, "filehtml": "", "fmtphtml": "" };
            tempmodel.XXFBDataList.pushArray([{ "index": 0, "ID": 0, "XXTitle": "", "XXContent": "", "Files": "", "Author": "", "ImageIds": "", isselect: true, isshow: true, "filehtml": "", "fmtphtml": "" }, { "index": 1, "ID": 0, "XXTitle": "", "XXContent": "", "Files": "", "Author": "", "ImageIds": "", isselect: false, isshow: false, "filehtml": "", "fmtphtml": "" }, { "index": 2, "ID": 0, "XXTitle": "", "XXContent": "", "Files": "", "Author": "", "ImageIds": "", isselect: false, isshow: false, "filehtml": "", "fmtphtml": "" }, { "index": 3, "ID": 0, "XXTitle": "", "XXContent": "", "Files": "", "Author": "", "ImageIds": "", isselect: false, isshow: false, "filehtml": "", "fmtphtml": "" }, { "index": 4, "ID": 0, "XXTitle": "", "XXContent": "", "Files": "", "Author": "", "ImageIds": "", isselect: false, isshow: false, "filehtml": "", "fmtphtml": "" }]);

            tempmodel.XXFBData = tempmodel.XXFBDataList[0];
            // 编辑器赋值
            var um = UM.getEditor("conXXNR");
            var content = tempmodel.XXFBData.XXContent;
            um.setContent(content);
            setTimeout("ComFunJS.initForm()", 500)
        }, chkshowhide: function (checkid) {
            switch (checkid) {
                case 1:
                    tempmodel.modelData.isPL = !tempmodel.modelData.isPL;
                    break;
                case 2:
                    tempmodel.modelData.IsSecret = !tempmodel.modelData.IsSecret;
                    break;
                case 3:
                    tempmodel.timeShow = !tempmodel.timeShow;
                    if (!tempmodel.timeShow) {
                        tempmodel.modelData.FBTime = "";
                    }
                    break;
            }
        }

    });
    tempmodel.$watch("showindex", function (a, b) {
        // 编辑器赋值
        var um = UM.getEditor("conXXNR");
        var content = tempmodel.XXFBDataList[tempmodel.showindex].XXContent;
        um.setContent(content);

        setTimeout("ComFunJS.initForm()", 500)

    })
    //# sourceURL=XXFB.js;
</script>

<style>
    .form-group {
        overflow: hidden;
    }
</style>
<link href="/ViewV5/AppPage/XXFB/WX.css" rel="stylesheet" />
<div class="form-horizontal" ms-controller="XXFB">
    <div style="margin-right:400px;">
        <div class="form-group">
            <label class="col-xs-2 control-label"><i>*</i>信息分类</label>
            <div class="col-xs-4">
                <select class="form-control szhl_require" ms-duplex="modelData.XXFBType" ms-change="TypeIsCheck()" id="conXXType">
                    <option value="" ms-attr-selected="modelData.XXFBType==''?'selected':''">请选择</option>
                    <option ms-repeat-item="ColumnData" ms-attr-value="item.ID" ms-attr-selected="item.ID==modelData.XXFBType?'selected':''">{{item.TypeName}}</option>
                </select>
            </div>
            <div class="col-xs-4">
                <a class="btn btn-link" ms-click="GetDraftInfo('SelDraft','选择企业草稿')">选择草稿</a>
                <a class="btn btn-link" ms-click="GetDraftInfo('SelMatterDraft','选择素材')">选择素材</a>
            </div>
        </div>
        <div class="form-group" ms-if="modelData.SHUser!=''">
            <label class="col-xs-2 control-label">审核人</label>
            <div class="col-xs-4">
                <label class="control-label">{{ComFunJS.convertuser(modelData.SHUser)}}</label>
            </div>
        </div>
        <div class="form-group" style="margin-bottom:0">
            <label class="col-xs-2 control-label"><i>*</i>消息接收人员</label>
            <div class="col-xs-9">
                <input type="text" value="" class="form-control  szhl_getPeoples" ms-attr-usertype="isAnyUser==1?'XXFB':''" ms-attr-typeid="modelData.XXFBType" ms-duplex="modelData.JSUser" id="qygg2" />
            </div>
        </div>
        <div class="form-group oh" style="padding-top: 10px;">
            <label class="col-xs-2"></label>
            <div class="col-xs-9">
                <div class="checkbox checkbox-inline" ms-click="chkshowhide(1)" style="padding-left:0px">
                    <div class="icheckbox_square-blue" ms-class-1="checked:modelData.isPL" id="inlineCheck1">
                        <input type="checkbox" id="inlineCheckbox1" ms-duplex-checked="modelData.isPL">
                        <span class="iconfont icon-check ft12"></span>
                    </div>

                    <label style="padding:0">是否需要评论 </label>
                </div>


                <div class="checkbox checkbox-inline" ms-click="chkshowhide(2)" style="padding-left: 0px">
                    <div class="icheckbox_square-blue" ms-class-1="checked:modelData.IsSecret" id="inlineCheck2">
                        <input type="checkbox" id="inlineCheckbox2" ms-duplex-checked="modelData.IsSecret">
                        <span class="iconfont icon-check ft12"></span>
                    </div>
                    <label style="padding:0">是否加水印 </label>
                </div>


                <div class="checkbox checkbox-inline" ms-click="chkshowhide(3)" ms-if="!modelData.FBTime" style="padding-left: 0px">
                    <div class="icheckbox_square-blue" ms-class-1="checked:timeShow" id="inlineCheck3">
                        <input type="checkbox" id="inlineCheckbox3" ms-duplex-checked="timeShow">
                        <span class="iconfont icon-check ft12"></span>
                    </div>
                    <label style="padding:0"> 定时 </label>
                </div>


                <div class="col-xs-5 pull-right" style="padding-right:0px;padding-left:0px;">
                    <label ms-if="modelData.FBTime" style="float:left;line-height:30px;vertical-align:middle">时间&nbsp;</label>
                    <input type="text"  class="form-control szhl_form_date_time" style="width:145px;" novalue="" ms-duplex="modelData.FBTime" ms-visible="timeShow||modelData.FBTime" placeholder="请填写定时时间" />

                </div>
            </div>
        </div>
        <div>

            <!-- Tab panes -->
            <div class="tab-content">
                <div role="tabpanel" class="tab-pane fade active in" id="dt0">
                    <div class="form-group">
                        <label class="col-xs-2 control-label">
                            <i>*</i> 信息标题
                        </label>
                        <div class="col-xs-9">
                            <input type="text" class="form-control szhl_require" ms-duplex="XXFBDataList[showindex].XXTitle" />
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-xs-2 control-label">
                            作者
                        </label>
                        <div class="col-xs-9">
                            <input type="text" class="form-control" ms-duplex="XXFBDataList[showindex].Author" />
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-xs-2 control-label">封面图片</label>
                        <div class="col-xs-9" id="confmtp">
                            <input type="text" class="szhl_Upload form-control" ms-duplex="XXFBDataList[showindex].ImageIds" />
                        </div>
                    </div>
                    <div class="form-group" id="confujian">
                        <label class="col-xs-2 control-label">附件</label>
                        <div class="col-xs-9">
                            <input type="text" value="" class="szhl_Upload form-control" ms-duplex="XXFBDataList[showindex].Files" />
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-xs-2 control-label">信息内容</label>
                        <div class="col-xs-9">
                            <textarea id="conXXNR" class="szhl_UEEDIT" umheight="400" ms-duplex="XXFBDataList[showindex].XXContent"></textarea>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div style="position:absolute;width:400px;right:0;top:0">
        <div>
            <!-- <div class="js_arrow mod-tranlate-right"></div> -->
            <div class="mc_content_item">
                <div class="mc_card_wrap clearfix">
                    <div class="video_unit">
                        <div class="js_list">
                            <!-- 当选中的时候，添加class：active和delete，其中active用来显示蓝色边框delete用来显示删除按钮；ps：当video_artical数量大于两个的时候，video_artical选中的时候才出现关闭按钮 -->
                            <a class="js_article video_image" ms-repeat-el="XXFBDataList" ms-visible="$first" ms-class-1="active:el.isselect" ms-click="SelTab(el)">
                                <div class="choose_mode_style"></div>
                                <span class="js_delete icon icon_delete delete_artical"></span>
                                <div class="video_image_wrap" ms-visible="el.ImageIds!=''">
                                    <img ms-attr-src="{{ComFunJS.getfile(el.ImageIds)}}">
                                </div>
                                <p class="image_edit_placeholder" ms-visible="el.ImageIds==''">
                                    <span class="placeholder_text">封面图片<br>推荐尺寸:900像素*500像素</span>
                                    <span class="placeholder_vertical"></span>
                                </p>
                                <p class="js_article_title video_sub_title" style="margin-bottom:0">{{el.XXTitle}}</p>
                            </a>
                            <a class="js_article video_artical  delete" href="javascript:;" ms-repeat-el="XXFBDataList" ms-visible="!$first&&el.isshow" ms-class-1="active:el.isselect" ms-click="SelTab(el)">
                                <div class="choose_mode_style" ms-visible="el.isselect"></div>
                                <span class="delete_artical label label-danger" ms-click="hidTab(el,$event)">X</span>
                                <img class="video_artical_img" ms-visible="el.ImageIds!=''" ms-attr-src="{{ComFunJS.getfile(el.ImageIds)}}">
                                <p class="image_edit_placeholder" ms-visible="el.ImageIds==''"></p>
                                <p class="js_article_title video_artical_title" style="margin-top: 30px; font-size: 18px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; height: 40px; width: 75%; ">{{el.XXTitle}}</p>
                                <span class="video_vertical"></span>
                            </a>
                        </div>
                        <a class="js_create video_artical_add" href="javascript:;" style="display: block;" ms-if="!strModelId" ms-click="ShowTab()">
                            <span class="video_artical_add_button">
                                <i class="iconfont icon-addplus" style="font-size:40px"></i>
                            </span>
                        </a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>